/*
 * PrecioHoraSharpPane.java
 *
 * Created on 27 de junio de 2006, 04:49 PM
 */

package inc.jmc.cyberboard.ztrashcan;
import javax.swing.*;
import java.awt.*;

/**
 *
 * @author  juolguin
 */
public class PrecioHoraSharpPane extends javax.swing.JPanel {
    
    /** Creates new form PrecioHoraSharpPane */
    static String error1="Error en los tipos de datos o faltan llenar campos";
    
    java.text.NumberFormat nf= java.text.NumberFormat.getInstance();
    public PrecioHoraSharpPane() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        borrarBtn = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        precioHoraTextField2 = new javax.swing.JTextField();
        preciominutoTxt2 = new javax.swing.JTextField();

        setLayout(null);

        jPanel1.setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "primera hora", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14)));
        borrarBtn.setText("Quitar esta tarifa");
        borrarBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                borrarBtnActionPerformed(evt);
            }
        });

        jPanel1.add(borrarBtn);
        borrarBtn.setBounds(380, 90, 130, 23);

        jLabel6.setText("Precio por hora");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(10, 30, 120, 14);

        jLabel7.setText("Precio del minuto");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(10, 50, 120, 14);

        precioHoraTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                precioHoraTextField2FocusLost(evt);
            }
        });

        jPanel1.add(precioHoraTextField2);
        precioHoraTextField2.setBounds(170, 30, 70, 19);

        preciominutoTxt2.setEditable(false);
        jPanel1.add(preciominutoTxt2);
        preciominutoTxt2.setBounds(170, 50, 70, 19);

        add(jPanel1);
        jPanel1.setBounds(10, 10, 520, 120);

    }// </editor-fold>//GEN-END:initComponents

    private void borrarBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_borrarBtnActionPerformed
        javax.swing.JPanel pan =(javax.swing.JPanel)getParent();
        pan.remove(this);
        pan.updateUI();
    }//GEN-LAST:event_borrarBtnActionPerformed

    private void precioHoraTextField2FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_precioHoraTextField2FocusLost
        try{
            float precioHora=Float.parseFloat(precioHoraTextField2.getText());
            float montounitario=(precioHora/60);
            preciominutoTxt2.setText(""+nf.format(montounitario));
        } catch(java.lang.NumberFormatException ex) {
            if(precioHoraTextField2.getText()!=null && !precioHoraTextField2.getText().equals(""))
                JOptionPane.showMessageDialog(this,error1,"Error en los datos proporcionados",JOptionPane.ERROR_MESSAGE);
        } catch(Exception ex) {
            if(precioHoraTextField2.getText()!=null && !precioHoraTextField2.getText().equals(""))
                JOptionPane.showMessageDialog(this,ex.getMessage(),"Error en los datos proporcionados",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_precioHoraTextField2FocusLost
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton borrarBtn;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField precioHoraTextField2;
    private javax.swing.JTextField preciominutoTxt2;
    // End of variables declaration//GEN-END:variables
    
}
